#!/bin/bash

## Files and cmd
FILE="$HOME/.cache/eww_launch_side.xyz"
EWW="$HOME/.local/bin/eww/eww -c $HOME/.config/eww/leftbar"

# windows not in use
# separ

## window list
w_ls="
    main \
    pfp \
    song \
    sys_usg \
    song_prog \
    song_ctl \
    audio \
    quote \
    sys_tray \
    time
"
## Run eww daemon if not running already
if [[ ! `pidof eww` ]]; then
	${EWW} daemon
	sleep 1
fi

# widgets not in use
# apps
# twitter
# volume
# fetch

## Open widgets 
run_eww() {
    ${EWW} open-many $w_ls
}

## Launch or close widgets accordingly
if [[ ! -f "$FILE" ]]; then
	touch "$FILE"
	run_eww 
else
    ${EWW} close $w_ls 
	rm "$FILE"
fi
